﻿using Volo.Abp.DependencyInjection;
using Volo.Abp;
using CTP.CRM.Core.SharedModel.Pub;

namespace CTP.CRM.Core.SharedModel.InternalCore.Token
{
    public class DefaultSecurityKeyProvider : ISecurityKeyProvider, ISingletonDependency
    {
        private static readonly Dictionary<string, string> KEY = new Dictionary<string, string>
    {
        { "DEV", "775yOxSMHVdYjs61gkgUY3W9DHbgk7tokaZlP3QIlfk34D1H7jYEOcLybClW1aLL" },
        { "TEST", "KwE3qiH0EWp63TlyAkr3WR47s4LVUlIqbLSD3egYCtSVnzqbMQb7kTJBqn764M4C" },
        { "UAT", "Uvd1mTBhI0XCqRAvRSDlc4cQxoAssKEq5ltTZ4mz870xDGSI7A32QR7vMWKPxFS9" },
        { "PRODUCT", "64TFwbsTBbL8NrOjlosKdxai5G1uggxj8C4fQt2EzyU5mSa0xvltKCKYjL0AUlAC" }
    };

        public string GetSecurityKey(string env)
        {
            return TryGetjWtKey(env);
        }

        private static string TryGetjWtKey(string env)
        {
            ThrowHelper.ThrowIfEmpty(env, "读取环境参数失败，请联系管理员!", "TryGetjWtKey", 23, "env");
            env = env.ToUpper();
            if (KEY.ContainsKey(env))
            {
                return KEY[env];
            }

            throw new BusinessException("400", "解析环境参数失败，请联系管理员!");
        }
    }
}
